package com.czhi.multi;

import com.lmax.disruptor.RingBuffer;

public class Producer {

    private RingBuffer<Order> ringBuffer;

    public Producer(RingBuffer<Order> ringBuffer) {
        this.ringBuffer = ringBuffer;
    }

    public void sentData(String value){
        final long sequence = ringBuffer.next();
        try {
            final Order order = ringBuffer.get(sequence);
            order.setId(value);
        } finally {
            ringBuffer.publish(sequence);
        }
    }
}
